Manager role management
RoleManager
Manager role management.
class yandex_b2b_go.role.RoleManager
Methods
- list — gets the list of roles of the department's managers.
- create — assigns the role to the department manager.
- update — updates the role of the department manager.
- delete — deletes an existing role of the department manager.
List
Gets a list of roles of the department's managers.
async def list(
roles: Optional[List[Role]] = None,
department_id: Optional[str] = None,
limit: Optional[int] = None,
cursor: Optional[str] = None
) -> ManagersListResponse
Parameters
department_id— department ID.roles— list of roles to display. List of theRoleclass (link to typing.Role)limit— number of records to display. Value from 1 to 100. If this parameter is not specified, information about the first 10 records is returned.cursor— request marker (returned in the body of response to the previous request). The parameter is not required for the first page, but is required for subsequent pages.
If successful, returns the ManagersListResponse class.
If the parameters are incorrect, the method returns the ValidationError error.
If the response code is not 200, an error is returned: ApiError.
Request example
import asyncio
from yandex_b2b_go import Client
from yandex_b2b_go import RoleManager
from yandex_b2b_go import typing, errors
TOKEN = '<your token>'
async def main():
client = Client(token=TOKEN)
role_manager = RoleManager(client=client)
try:
roles = await role_manager.list(
limit=20,
roles=[typing.Role.department_manager, typing.Role.department_secretary],
)
...
except errors.ValidationError as e:
return str(e.args)
except errors.ApiError as e:
return e
asyncio.run(main())
Create
Assigns the role to the department manager. You can see the roles that can be assigned to a user in their account.
async def create(manager: Manager) -> ManagerResponse
Parameter
manager— information about the manager role. Class Manager.
If successful, the ManagerResponse class is returned.
If the parameters are incorrect, the method returns the ValidationError error.
If the response code is not 200, an error is returned: ApiError.
Request example
import asyncio
from yandex_b2b_go import Client
from yandex_b2b_go import RoleManager
from yandex_b2b_go import typing, errors
TOKEN = '<your token>'
async def main():
client = Client(token=TOKEN)
role_manager = RoleManager(client=client)
try:
manager = typing.Manager(
yandex_login='sample_yandex_login',
role=typing.Role.department_manager,
department_id='3648...396b',
phone='+799900000000',
email='sample_email@example.com',
fullname='Ilya Ivanov',
)
role_id = await role_manager.create(manager=manager)
...
except errors.ValidationError as e:
return str(e.args)
except errors.ApiError as e:
return e
asyncio.run(main())
Update
Updates the role of the department manager. You can see the roles that can be assigned to a user in their account.
async def update(
manager_id: str,
manager: Manager
) -> ManagerResponse
Parameters
manager_id— ID of the department manager whose role is being updated.manager— information about the manager role. Class Manager.
If successful, the ManagerResponse class is returned.
If the parameters are incorrect, the method returns the ValidationError error.
If the response code is not 200, an error is returned: ApiError.
Request example
import asyncio
from yandex_b2b_go import Client
from yandex_b2b_go import RoleManager
from yandex_b2b_go import typing, errors
TOKEN = '<your token>'
async def main():
client = Client(token=TOKEN)
role_manager = RoleManager(client=client)
try:
manager = typing.Manager(
yandex_login='sample_yandex_login',
role=typing.Role.department_manager,
department_id='3648...396b',
phone='+799900000000',
email='sample_email@example.com',
fullname='Ilya Ivanov',
)
role_id = await role_manager.update(
manager=manager,
manager_id='07e4...b2f4',
)
...
except errors.ValidationError as e:
return str(e.args)
except errors.ApiError as e:
return e
asyncio.run(main())
Delete
Delete an existing role of the department manager.
async def delete(manager_id: str) -> ManagerResponse
Parameter
manager_id— ID of the department manager whose role is being updated.
If successful, the ManagerResponse class is returned.
If the parameters are incorrect, the method returns the ValidationError error.
If the response code is not 200, an error is returned: ApiError.
Request example
import asyncio
from yandex_b2b_go import Client
from yandex_b2b_go import RoleManager
from yandex_b2b_go import errors
TOKEN = '<your token>'
async def main():
client = Client(token=TOKEN)
role_manager = RoleManager(client=client)
try:
role_id = await role_manager.delete(
manager_id='07e4...b2f4',
)
...
except errors.ValidationError as e:
return str(e.args)
except errors.ApiError as e:
return e
asyncio.run(main())